<template>
	<view class="goods_Box">
		<view class="goods_list_item" v-for="(item,index) in list" :key="index"
		 @tap="navTo(item)">
			<view class="main">
				<view class="show_img">
					<text :class="['title',item.status==3?'title1':'title2']">{{setTitle(item)}}</text>
					<text class="version ">版号：{{item.metafile.publishNo || ""}}</text>
					<view v-if="isImage(item.fileUrl) == 'mp4'">
						<image class="img" :src="item.fileUrl+'?x-oss-process=video/snapshot,t_0,f_jpg'" mode="widthFix"></image>
					</view>
					<view v-else-if="isImage(item.fileUrl) == 'mp3'">
						<audio class="audioBox" :src="item.fileUrl" :controls="true"></audio>
					</view>
					<view v-else>
						<image class="img" :src="item.fileUrl" mode="widthFix">
						<!-- <image class="img" :src="pathImg+item.fileUrl+'?x-oss-process=image/format,png'" mode="widthFix"> -->
						</image>
					</view>
				</view>
				<view class="goods_desc">
					<view class="desc">
						<view class="desc_title">
							{{item.titleNM || ''}}
						</view>
						<image v-if="setImgShow(item) == 1" src="@/static/home/fileType1.png" mode="widthFix"></image>
						<image v-if="setImgShow(item) == 2" src="@/static/home/fileType2.png" mode="widthFix"></image>
						<image v-if="setImgShow(item) == 3" src="@/static/home/fileType3.png" mode="widthFix"></image>
					</view>
					
					<view class="goods_limit">
						<view class="owner">
							<image class="imgHead" :src="item.issuerHead[0]" mode="scaleToFill"></image>
							<view class="owner-name">{{item.issuerName}}</view>
						</view>
					</view>
					<view class="owner-price" :style="{'justify-content':item.bsType != 1?'space-between':'center'}">
						<view class="priceBox" v-show="item.bsType != 1">￥<text>{{item.price || 0}}</text></view>
						<text>{{item.bsType | setButnTxt}}</text>
					</view>
				</view>
			</view>
		</view>
		<view class="more" v-if="isMore" @tap="goPage('/pages/newProduct/goodsList')"><text>查看更多</text></view>
		<view class="msg" v-if="isEnd">— 更多内容敬请期待 —</view>
	</view>
	
</template>

<script>
	export default {
		props:{
			list:{
				type:Array,
				default:[]
			},
			isMore:{
				type:Boolean,
				default:false
			},
			isEnd:{
				type:Boolean,
				default:false
			}
		},
		data() {
			return {
				isAppPlus:true
			}
		},
		onShow() {
			// #ifdef APP-PLUS
				this.isAppPlus = false;
			// #endif
		},
		methods:{
			goPage(url){
				uni.navigateTo({
					url,
				});
			},
			setImgShow(cur){
				if(cur.metafile.FileType){
					if(cur.metafile.FileType == ".glb"){
						return 3;
					}else if(cur.metafile.FileType == ".mp4"){
						return 2;
					}else{
						return 1;
					}
				}
				return 0;
			},
			//status  1发售中2待售3结束
			setTitle(cur){
				let str = "抢购中";
				if(cur.status == 3){
					str = "首发售罄";
				}else if(cur.status == 4){
					str = "抽签中";
				}else if(cur.status == 1){
					if(cur.bsType == 0){//发售
						str = "发售中";
					}else if(cur.bsType == 1){//空投
						str = "发放中";
					}else if(cur.bsType == 9){//抢购
						str = "抢购中";
					}
				}else if(cur.status == 2){
					str = "预售中";
				}
				return str;
			},
			// 判断藏品是否是图片
			isImage(url) {
				if (url) {
					let filePath = url.toLocaleLowerCase();
					if (filePath.indexOf(".mp4") != -1) {
						return 'mp4';
					} else if (filePath.indexOf(".mp3") != -1) {
						return 'mp3';
					} else {
						return 'img';
					}
				}
			},
			navTo(cur, index,i) {
				// 类型：0：购买，1：空投，9抢购
				let url  = "";
				if(cur.bsType == 9){
					url = '/pages/detail/index?id='+cur.applyId+'&path=sale';
				}else{
					url = '/pages/detail/goodsInfo?id='+cur.id+'&path=home';
				}
				uni.navigateTo({
					url,
				})
			},
		},
		filters:{
			setButnTxt(data){
				let str = "";
				// 类型：0：购买，1：空投，9抢购
				if(data || data == 0){
					if(data == 1){
						str = "领取";
					}else{
						str = data==9?"抢购":"抢购";
					}
				}
				return str;
			}
		}
	}
</script>

<style scoped lang="less">
	.goods_Box{
		display: flex;
		align-items: flex-start;
		justify-content: space-between;
		flex-wrap: wrap;
		padding: 0 30upx;
		padding-bottom: 40upx;
		.goods_list_item {
			width: 50%;
			position: relative;
			overflow: hidden;
			padding-bottom: 40upx;
			.main {
				overflow: hidden;
				background-color: #fff;
				position: relative;
				border-radius: 25upx;
				padding-bottom: 20upx;
				.startBox{
					position: absolute;
					top: 20upx;
					left: 20upx;
					z-index: 2;
					display: flex;
					justify-content: center;
					align-items: center;
					padding:4upx 12upx;
					border-radius: 10upx;
					background-color: rgba(0,0,0,0.8);
					color: #17A814;
					font-size: 24upx;
					>text{
						display: inline-block;
						margin-right: 10upx;
						height: 100%;
						line-height: 24upx;
					}
					/deep/.u-count-down__text{
						color: #17A814;
						font-size: 24upx;
					}
				}
				.show_img {
					width: 100%;
					height:288upx;
					border-radius: 25upx;
					position: relative;
					overflow: hidden;
					.version{
						display: inline-block;
						text-align: center;
						position: absolute;
						left: 0;
						bottom: 30upx;
						width: 100%;
						color: #fff;
						font-size: 16upx;
						z-index: 2;
					}
					.title{
						display: inline-block;
						position: absolute;
						top: 0;
						left: 50%;
						margin-left: -91upx;
						text-align: center;
						font-size: 20upx;
						font-weight: bold;
						width: 182upx;
						height: 34upx;
						line-height: 34upx;
						z-index: 2;
						color: #fff;
						background-size: 100% 100%;
						background-repeat: no-repeat;
					}
					.title1{
						background-image: url(../../../static/home/title1.png);
					}.title2{
						background-image: url(../../../static/home/title2.png);
					}
					>view{
						width: 100%;
						height: 100%;
						position: relative;
						overflow: hidden;
						display: flex;
						align-items: center;
					}
					.img {
						width: 100%;
						display: block;
					}
		
					.audioBox {
						display: block;
						min-width: 100%;
						
						/deep/.uni-audio-default {
							display: block;
							min-width: 100%;
						}
					}
				}
		
				.goods_desc {
					width: 100%;
					padding: 0 20upx;
					padding-top: 20upx;
					position: relative;
					
					.desc {
						display: flex;
						align-items: center;
						justify-content: space-between;
						image{
							width: 26upx;
						}
						.desc_title {
							flex: 1%;
							padding-right: 16upx;
							font-size: 24upx;
							font-family: PingFang SC;
							font-weight: bold;
							color: #333;
							overflow: hidden;
							white-space: nowrap;
							text-overflow: ellipsis;
							-o-text-overflow:ellipsis;
						}
					}
					.goods_limit{
						.owner {
							display: flex;
							justify-content: flex-start;
							align-items: center;
							padding-top: 22upx;
							.imgHead {
								border-radius: 50%;
								width: 34upx;
								height: 34upx;
								box-shadow: 0 0 6px 3px rgba(0,0,0,0.1);
							}
								
							.owner-name {
								flex: 1%;
								display: inline-block;
								line-height: 24upx;
								margin-left: 10upx;
								font-size: 24upx;
								font-family: PingFang SC;
								font-weight: 500;
								color: #666;
								overflow: hidden;
								white-space: nowrap;
								text-overflow: ellipsis;
								-o-text-overflow:ellipsis;
							}
						}
					}
					.owner-price {
						width: 100%;
						display: flex;
						margin-top: 30upx;
						align-items: center;
						height: 62upx;
						justify-content: space-between;
						>text{
							display: inline-block;
							color: #fff;
							font-size: 20upx;
							height: 36upx;
							width: 102upx;
							background: #EB5703;
							border-radius: 18upx;
							text-align: center;
							line-height: 36upx;
						}
						.priceBox{
							font-size: 28upx;
							color:#2C1769;
							text{
								padding-left: 6upx;
								font-size: 46upx;
							}
						}
					}
				}
			}
		
		}
		.goods_list_item:nth-child(odd){
			padding-right: 15upx;
		}
		.goods_list_item:nth-child(even){
			padding-left: 15upx;
		}
		.more {
			width: 100%;
			text-align: center;
			>text{
				display: inline-block;
				width: 220upx;
				height: 46upx;
				text-align: center;
				line-height: 42upx;
				color: #333;
				font-size: 24upx;
				margin-top: 30upx;
				border-radius: 16upx;
				border: 1px solid #2C1769;
				margin: 0 auto;
				color: #2C1769;
			}
		}
		.msg {
			width: 100%;
			text-align: center;
			color: #333;
			font-size: 24upx;
			margin-top: 30upx;
			// padding-bottom: 100upx;
		}
	}
</style>
